package ch.cn.hdmidemo;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;


public class BootCompleteReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        Bundle bundle = intent.getExtras();
        String action = intent.getAction().toString();
        Log.e("BootCompleteReceiver", "[MyReceiver] onReceive - " + action + ", extras: ");


        if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {

            Log.e("BootCompleteReceiver1", "COMPLETED===");//

            Intent intentMainActivity = new Intent(context, MainActivity.class);
            intentMainActivity.setAction("android.intent.action.MAIN");
            intentMainActivity.addCategory("android.intent.category.LAUNCHER");
            intentMainActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intentMainActivity);  //跳转到首页
            Toast.makeText(context, "开自启动成功", Toast.LENGTH_LONG).show();    //自启动
        }

    }

}